<template>
    <div class="studentList">
        <!-- 查询、重置 -->
        <el-table :data="dataList" border style="width: 1000px;margin-left: 50px">
            <el-table-column  prop="bussinessImgUrl" label="商品图片" width="200" align="center" >
                <template slot-scope="scope">
                    <el-image :src="imgurl+scope.row.bussinessImgUrl" style="width:50px;height:60px"
                              @click="setN(scope.row)">
                    </el-image>
                </template>
            </el-table-column>
            <el-table-column prop="productName" label="商品名称"   width="200" @click="setN(scope.row)" align="center">
            </el-table-column>
            <el-table-column prop="price" label="价格" width="200"  align="center">
            </el-table-column>
            <el-table-column prop="descript" label="商品描述" align="center" width="250px">
            </el-table-column>

<!--            <el-table-column label="操作" align="center">-->
<!--                <template slot-scope="scope">-->
<!--                    <el-button-->
<!--                            type="primary"-->
<!--                            @click="setN(scope.row)"-->
<!--                    >编辑-->
<!--                    </el-button>-->
<!--                </template>-->
<!--            </el-table-column>-->
        </el-table>

        <el-pagination
                class="pagiantion"
                @current-change="handleCurrentChange"
                :current-page="pagination.currentPage"
                :page-size="pagination.pageSize"
                layout="total, prev, pager, next, jumper"
                :total="pagination.total">
        </el-pagination>
    </div>
</template>
<script>
    import {getProduct} from "../../../api/api";
    import {getToken} from "../../../utill/Token";
    import {setToken} from "../../../utill/Token";


    export default {
        data() {
            return {
                dataList: [],
                formData: "",
                imageUrl:"",
                productList:[{id:0,title:"下架"},{id:1,title:"上架"}],
                search: {},
                pagination: {
                    currentPage: 1, //当前页数
                    pageSize: 10, // 每页显示条数
                    total: 0, // 总条数
                    productCore: "",
                    bussinessId: "",
                    auditStatus: "",
                    productName: "",
                    categoryId:""
                },
                form: {},
                subjectOneList:[],  //一级分类
                subjectTwoList:[],
                imgurl: "http://localhost:8080/images/",
                formInline: {
                    name: "",
                },
                formLabelWidth: "100px",
            };
        },
        created() {
            this.pagination.categoryId = getToken("categoryId");
            this.pagination.bussinessId = getToken("bussiness_id")
            this.getData();
        },
        computed: {

        },
        methods: {
            handleCurrentChange(currentPage) {
                //修改页码值为当前选中的页码值
                this.pagination.currentPage = currentPage;
                //执行查询
                this.getData();
            },
            getData() {

                getProduct(this.pagination).then((res) => {
                    if (res.data.status === 200) {
                        this.dataList = res.data.data.records;
                        this.pagination.total = res.data.data.total;
                        console.log(res.data.data.records)
                    }
                });

            },
            setN(row) {
                this.form = {...row}
                console.log(this.form.productId)
                setToken("productId",this.form.productId)
                this.$router.push({path: '/flowerMarket/details'} );
            },


        }
    };
</script>
<style lang="scss">
    .studentList {
        .demo-form-inline, .el-form-item {
            text-align: left;
            /*float: left;*/
            height: auto;
        }

        .el-input {
            width: auto; // 这里一定要设置为auto 否则由于input是默认width ：100%的
            height: auto;
        }

        .form_item {
            //   border-style: dashed dotted double groove;
            text-align: left;
            width: 100%;
        }

        .btn {
            display: inline-block;

        }

        .el-pagination {
            text-align: left;
            margin-top: 20px;
        }
    }  .deleteImg {
           font-size: 30px;
           position: absolute;
           top: 0;
           right: 0;
           z-index: 999;
       }
    img {
        width: 50%;
        height: 100%;
        background-repeat: no-repeat;
    }


</style>
